<me:UIVRK x:Class="WPFExcelReport.TVRKOPF"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
          xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL"  
                     xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                    xmlns:KD="clr-namespace:WPFExcelReport;assembly=TKDSTAMM"  
                    xmlns:HR="clr-namespace:WPFExcelReport;assembly=THRSTAMM"  
                    xmlns:DR="clr-namespace:WPFExcelReport;assembly=TDRAUFTR" 
                    xmlns:ZA="clr-namespace:WPFExcelReport;assembly=TZABED"   
                    xmlns:VRP="clr-namespace:WPFExcelReport;assembly=TVRPOS" 
                    xmlns:VKP="clr-namespace:WPFExcelReport;assembly=TVKPOS"     
                    xmlns:ZB="clr-namespace:WPFExcelReport;assembly=TVKZUAB"    
                    xmlns:TXT="clr-namespace:WPFExcelReport;assembly=TTXTIND"   
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIVRK.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTBoolToVisibilityConverter x:Key="nbv"/>
        <ucd:NOTConverter  x:Key="not"/>
        <ucd:Divideby100 x:Key="d100"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:UIVRK.Resources>
    <DockPanel IsEnabled="{Binding IsBusy,ElementName=TV,Converter={StaticResource not}}">
        <ex:AniScrollViewer DockPanel.Dock="Bottom" 
                        Visibility="{Binding IsShowBottom,ElementName=TV,Converter={StaticResource bv}}">
            <StackPanel >
                <ZB:TVKZUAB Name="cZBP" Margin="10" IsAuto="True"  MaxHeight="300"  
                            VKZSA="VK"
                            ORDERNUM="{Binding AUF,ElementName=cVKP}"  />
            </StackPanel>
        </ex:AniScrollViewer>
        <ex:AniScrollViewer DockPanel.Dock="Right" 
                    MaxWidth="400"
                    Visibility="{Binding IsShowRight,ElementName=TV,Converter={StaticResource bv}}" >
            <StackPanel>
                <KD:TKD    Name="cKD"
                    ORDERNUM="{Binding KUNDNR,ElementName=cVRK}"  
                            KDBLOCK="{Binding KDBLOCK,ElementName=TV}"   
                            待处理现金="{Binding 待处理现金,ElementName=cVRP}"   
                            已付款="{Binding 已付款,ElementName=cVRP}"   
                            已开票="{Binding 已开票,ElementName=cVRP}"     
                            IsSaved="{Binding IsSaved,ElementName=cVRP}"
                            IsEdit="{Binding IsEdit,ElementName=cVRP}" 
                            IsReload="{Binding IsKDReload,ElementName=cVRP}"
                            /> 
                <TXT:TXTITX Grid.Row="1"   Grid.Column="1"
                         Name="cTxt" 
                             TART="VKT"
                         IsAuto="False"
                         SIND="{Binding TXTISIND,ElementName=cVKP}"   
                        DEFTXT="{Binding DEFTXT,ElementName=cVKP}"  
                        />
            </StackPanel>
        </ex:AniScrollViewer>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="1*"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0" Grid.RowSpan="3" Visibility="{Binding KDBLOCK,ElementName=cKD,Converter={StaticResource bv}}">
                <TextBlock  
                            Margin="40"
                            FontSize="28" Foreground="Red"
                            Text="{Binding Source={Localization:Translate Word=改客户的信用已经超出，所有操做都可能禁止}}"
                       />
                <Button Click="BackToNormalCommand" 
                        Margin="40"
                        FontSize="28" Foreground="Red"
                        Content="{Binding Source={Localization:Translate Word=关闭此提示}}"></Button>
                <Button Click="KD02Command" 
                        Margin="40"
                        FontSize="28" Foreground="Red"
                        Content="{Binding Source={Localization:Translate Word=进入客户管理}}"></Button>
            </StackPanel>
            <Grid Grid.Row="1" Visibility="{Binding KDBLOCK,ElementName=cKD,Converter={StaticResource nbv}}"
                  >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="1*"></RowDefinition>
                    <RowDefinition Height="2*"></RowDefinition>
                </Grid.RowDefinitions>

                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>

                    <StackPanel Grid.Column="0">
                        <WrapPanel>
                            <WrapPanel Visibility="{Binding IsCanPay,ElementName=TV,Converter={StaticResource nbv}}">
                                <Button Content="{Binding Source={Localization:Translate Word=申请订单确认款}}" Click="VKKStartPaymentCommand" />
                                <Button Content="{Binding Source={Localization:Translate Word=申请提货款}}" Click="VVStartPaymentCommand" />
                                <Button Content="{Binding Source={Localization:Translate Word=申请尾款}}" Click="RESTPaymentCommand" /> 
                            </WrapPanel> 
                        </WrapPanel>
                        <WrapPanel>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"  
                              Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                    <Button.Background>
                                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                                    </Button.Background>
                                </Button>
                            </Grid>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=订单类型}}"/>
                                <TextBlock Grid.Column="1" FontSize="16"   
                              Text="{Binding AUFTYP,ElementName=TV}" Width="20" />
                            </Grid>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=订单号}}"/>
                                <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2" PRE="  "   IsAutoClear="True" CharacterCasing="Upper" 
                              Text="{Binding KRS,ElementName=TV}" Width="30" />
                                <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  IsAutoClear="True" PRE="000000" 
                              Text="{Binding LFD,ElementName=TV}" KeyUp="AUF_Enter" Width="90" />
                            </Grid>
                            <Grid Margin="10,0,0,0"  VerticalAlignment="Top">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button Grid.Column="0"  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                    <Button.Background>
                                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                                    </Button.Background>
                                </Button>
                                <TextBlock Grid.Column="2" FontSize="16" Text="{Binding Source={Localization:Translate Word=查询}}"/>
                            </Grid>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <DR:TDRAUFTR  Grid.Column="0" Name="cDR" DocType="{Binding PRTYPE,ElementName=TV}" PrintType="OpenExcel" />
                                <Button  Grid.Column="1"   Click="btnPrint_Click" Height="20" Margin="5,0,0,0" Width="Auto" Content="{Binding Source={Localization:Translate Word=打印}}" />
                            </Grid>
                        </WrapPanel>
                        <WrapPanel  VerticalAlignment="Top" IsEnabled="False">
                            <Grid Margin="10,0,0,0"  VerticalAlignment="Top"   
                              Visibility="{Binding IsCanNew,ElementName=TV,Converter={StaticResource bv}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button Grid.Column="0"  Click="NewCommand"
                                   
                                    Height="20" Margin="5,0,0,0" Width="24"  >
                                    <Button.Background>
                                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                                    </Button.Background>
                                </Button>
                            </Grid>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top"
                               Visibility="{Binding IsCanChg,ElementName=TV,Converter={StaticResource bv}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button  Click="EditCommand" Width="24" Height="20">
                                    <Button.Background>
                                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                                    </Button.Background>
                                </Button>
                            </Grid>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top" 
                               Visibility="{Binding IsCanDelete,ElementName=TV,Converter={StaticResource bv}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                    <Button.Background>
                                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                                    </Button.Background>
                                </Button>
                            </Grid>
                            <Grid Margin="10,0,0,0" VerticalAlignment="Top" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button    Click="CopyCommand" Height="20" Margin="5,0,0,0" Width="24" >
                                    <Button.Background>
                                        <ImageBrush  ImageSource="/ImagePackage;component/Images/copy.png" />
                                    </Button.Background>
                                </Button>
                            </Grid>
                            <WrapPanel  Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}">
                                <Grid Margin="10,0,0,0"  VerticalAlignment="Top" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=类型}}"/>
                                    <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2" PRE="  "   IsAutoClear="True" CharacterCasing="Upper" 
                              Text="{Binding AUFART,ElementName=TV}" Width="30" />
                                    <SD:K8886  Grid.Column="2" KEY="{Binding AUFART,ElementName=TV}" 
                                ORDERNUM="{Binding AUFART,ElementName=TV }"/>
                                </Grid>
                            </WrapPanel>
                        </WrapPanel>

                    </StackPanel>
                    <me:TVR04 Grid.Column="1" x:Name="cVRK"
                        ORDERNUM="{Binding KEY,ElementName=TV}" IsAuto="False"
                        IsNew="{Binding IsNew,ElementName=TV}"
                        IsEdit="{Binding IsEdit,ElementName=TV}"
                        IsSaved="{Binding IsSaved,ElementName=TV}"
                        IsShowBottom="{Binding IsShowBottom,ElementName=TV}"
                        IsShowTop="{Binding IsShowTop,ElementName=TV}"
                        IsShowLeft="{Binding IsShowLeft,ElementName=TV}"
                        IsShowRight="{Binding IsShowRight,ElementName=TV}"
               />

                </Grid>
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*"></ColumnDefinition>
                        <ColumnDefinition Width="1*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
               
                    <DataGrid  Grid.Column="0"
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"  
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}"  
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible">
                        <DataGrid.Columns>
                            <DataGridCheckBoxColumn Width="40" Binding="{Binding Path=IsSelected,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type DataGridRow}}}">
                                <DataGridCheckBoxColumn.HeaderTemplate>
                                    <DataTemplate>
                                        <CheckBox x:Name="ckbSelectedAll" Checked="ckbSelectedAll_Click" Unchecked="ckbSelectedAll_Unchecked"></CheckBox>
                                    </DataTemplate>
                                </DataGridCheckBoxColumn.HeaderTemplate>
                            </DataGridCheckBoxColumn>
                            <DataGridTextColumn Binding="{Binding Path=VRKRENR, Mode=TwoWay}"  Header="{Binding Source={Localization:Translate Word=发票}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKZAHLBED}"  Header="{Binding Source={Localization:Translate Word=付款方式}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRPAUFKRS, Mode=TwoWay}"   Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRPAUFLFD, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=销售单}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKGESWERTN, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=发票金额}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKWAWERT, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=货物价值}}" Width="Auto" />
                            <DataGridTextColumn Binding="{Binding Path=VRKZUAB, Mode=TwoWay}"   Header="{Binding Source={Localization:Translate Word=附加费}}" Width="Auto" />
                        </DataGrid.Columns>
                    </DataGrid  >
                    <VKP:TFVKP Grid.Column="1" 
                 Name="cVKP"
                         FTAUTOSUM="True"
                   TKEY1="总数量"
                   SKEY1="VKPSA" 
                   KEY1="VKPMENGE1" 
                   TKEY2="总金额"
                   SKEY2="VKPSA" 
                   KEY2="VKPPOSWERT" 
                 ORDERNUM="{Binding VVKP,ElementName=TV}"/>

                </Grid>
            
                <VRP:TVR05 Grid.Row="2"
                 Name="cVRP"
                 Margin="10,0,0,0"
                 ARTST="F"   
                 IsCanPay="{Binding IsCanPay,ElementName=TV}"
                 KUNDNR="{Binding KUNDNR,ElementName=cVRK}"
                 VKP="{Binding AUF,ElementName=cVKP}"
                 RENR="{Binding KEY,ElementName=cVRK}"
                 IsNew="{Binding IsNew,ElementName=TV}" 
                  FTAUTOSUM="True"
                  TKEY1="总数量"
                   SKEY1="VRPKOLL" 
                   KEY1="VRPMENGET4" 
                   TKEY2="总金额"
                   SKEY2="VRPKOLL" 
                   KEY2="VRPGESWERT"
                 IsFilterByVKP="True" 
                 IsShowRight="{Binding IsShowRight,ElementName=TV}"
                 IsShowBottom="{Binding IsShowBottom,ElementName=TV}"
                 IsEdit="{Binding IsEdit,ElementName=TV}"
                 IsSaved="{Binding IsSaved,ElementName=TV}"
                 />
            </Grid>
        </Grid>
    </DockPanel>
</me:UIVRK>
